<script type="text/javascript" src="<?=userassets?>core_js/pay_pass.js"></script>
<body>
<?=pay_passtemplate()?>
<?php  if ($my == "list") : ?>
<div class="container-fluid p-t-15">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                     <div class="panel-heading"><b class="panel-title"><?=$con?></b></div> 
                    <div style="float:right;">
                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addChannelModal">添加通道</button>
                    </div>
                    
                    <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>USDT地址</th>
                                    <th>收款人民币/USDT</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                              <?php 
                                foreach ($result as $res){
                                    $sql  = "SELECT sum(money) as money from pay_order where status='1' and qr_id='{$res['id']}'";
                                    $rmb  = executeSQLQuery($sql)['money']??'0.00';
                                    $sql  = "SELECT sum(price) as price  from pay_order where status='1' and qr_id='{$res['id']}'";
                                    $usdt = executeSQLQuery($sql)['price']??'0.00';
                                    $rowData = [
                                        ['label'=>$res['qr_url']],
                                        ['label'=>$rmb,'value'=>$usdt],
                                        ['label'=>$res['beizhu']],
                                        ['label'=>'<a href="javascript:;" onclick="editSave(\'' . $res['id'] . '\');" class="btn btn-xs btn-success"><i class="mdi mdi-pencil"></i>编辑 </a>	&nbsp;<a  href="javascript:;" onclick="Del_Qr(\'' . $res['id'] . '\');" class="btn btn-xs btn-danger">删除</a>'],
                                        ];
                                    $html .= Splicing_form($rowData);   
                                }
                                echo $html;
                                table_page($page,$pages,'usdt')
                                
                                ?>
                 </div>
            </div>
         </div>   
      </div>      
  </div>      
<?php endif; ?>	
<?php if ($my == "edit") : ?>
<div class="container-fluid p-t-15">
    <div class="row">
      <div class="col-md-12">
        <div class="card">
        <div class="card-body">  
         <input type="hidden" class="form-control" id="id" value="<?=$row['id']?>" >
         <div class="form-group">
              <label>USDT地址:</label><br>
               <input class="form-control" type="text" id="usdt_address" name="usdt_address" value="<?=$row['qr_url'];?>" >
        </div>
        <div class="form-group">
            <label>二维码备注:</label><br>
            <input type="text" class="form-control" id="beizhu" value="<?=$row['beizhu']?>" >
        </div>
        <div class="form-group">
            <label>二维码状态:</label><br>
            <select class="form-control" id="status" default="">
                <option value="1" <?= $row['status'] == '1' ? "selected" : "" ?>>开启</option>
                <option value="0" <?= $row['status'] == '0' ? "selected" : "" ?>>关闭</option>
             </select>  
          </div> 
         <button type="sumbit" class="btn btn-primary btn-block" onclick="edit_Qr();">确认以上并修改</button>	
<?php endif; ?>	
<div class="modal fade" id="addChannelModal" tabindex="-1" role="dialog" aria-labelledby="addChannelLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="addChannelLabel">添加新通道</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <!-- 表单 -->
                    <div class="form-group">
                        <label for="usdt_address">USDT-TRC20 收款地址：</label>
                        <input type="text" class="form-control" id="usdt_address" name="usdt_address">
                        <b>请确保地址正确，收款错误无法追回</b>
                    </div>
                    <div class="form-group">
                        <label for="beizhu">备注：</label>
                        <input type="text" class="form-control" id="beizhu" name="beizhu">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                  <button type="button" class="btn btn-primary" onclick="Add_usdt()">添加</button>
                </div>
        </div>
    </div>
</div>  
<script src="<?=userassets?>core_js/Del_Qr.js"></script>
<script src="<?=userassets?>core_js/usdt.js"></script>